package com.example.learn_mybatis.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.learn_mybatis.pojo.Pager;
import com.example.learn_mybatis.pojo.Permissions;
import com.example.learn_mybatis.mapper.PermissionsMapper;
import com.example.learn_mybatis.service.IPermissionsService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author chen
 * @since 2025-07-11
 */
@Service
public class PermissionsServiceImpl extends ServiceImpl<PermissionsMapper, Permissions> implements IPermissionsService {

    @Override
    public Pager getAllPermissions(Integer page, Integer size) {
        Page page1 = new Page(page, size);
        Pager pager = new Pager();

        Page permissionPage = this.page(page1);

        pager.setTotal(permissionPage.getPages());
        pager.setList(permissionPage.getRecords());

        return pager;
    }

    @Override
    public void getAllPermissionsNoPage() {
        this.baseMapper.selectByIds(null);
    }
}
